This is an automated monthly status report of the best practices
badge application covering the month <%= @month_display %>.

<%
if @last_stat_in_prev_month && @last_stat_in_prev_prev_month
%>
Here are some selected statistics for most recent completed month,
preceded by the same statistics for the end of the month before that.

<%= '%-35s' % 'Ending dates:'
%> <%=
  @last_stat_in_prev_prev_month.created_at.strftime('%Y-%m-%d')
%>  <%=
  @last_stat_in_prev_month.created_at.strftime('%Y-%m-%d') %>
<%
  Project::LEVEL_IDS.each do |level|
    ProjectStat::STAT_VALUES.each do |percentage|
      next if level.to_i != 0 && percentage.to_i.zero?
%><%= '%-35s' % ProjectStat.percent_field_description(level, percentage)
%> <%= '%10d' % @last_stat_in_prev_prev_month[
      ProjectStat.percent_field_name(level, percentage)]
%> <%= '%10d' % @last_stat_in_prev_month[
      ProjectStat.percent_field_name(level, percentage)]
%>
<%
    end  # do
  end # do
end # if (there are two stats)
%>

<%
new_achievements = false
Project::LEVEL_IDS.each do |level|
  if @projects[level.to_i] && !@projects[level.to_i].empty? %>

Here are the projects that first achieved
a <%= t("projects.form_early.level.#{level}") %> badge in <%= @month_display %>:

<%
    @projects[level.to_i].each do |project|
      new_achievements = true -%>
* <%= project.name %>
  at <%= project.achieved_passing_at %>
  https://<%= @hostname %>/projects/<%= project.id %>
<%
    end # loop over projects
%>
<%
  end # if there are projects at this level
end # loop over all levels
%>

<%
if new_achievements
%>
We congratulate them all!
<%
end
%>

Do you know a project that doesn't have a badge yet?
Please suggest to them that they get a badge now, by visiting:
https://<%= @hostname %>
